
(async function(){
    try {
        await Promise.all([
            interview('geekbang'),
            interview('tencent')
        ])

        console.log('smile')
    } catch(err) {
        console.log('cry for ' + err.name );
    }
})()


function interview(name) {
    return new Promise((resolve, reject) => {
        setTimeout(() => {
            if (Math.random() > 0.5) {
                resolve('success')
            } else {
                let error = new Error('fail');
                error.name = name;
                reject(error)
            }
        }, 500);
    });
}

